import { isCodeMessage } from "../config"
import { ReportType } from "@/type/report"

/**
 * @author: 小佘佘🦀
 * @description: 修改Report
 * @param {ReportType} report
 * */
export const updateReport = async (report: ReportType) => {


    const response = await fetch(`/api-backend/api/team/update`, {
        method: "POST",
        headers: {
            "content-type": "application/json;charset=utf-8",
        },
        body: JSON.stringify(report),
        redirect: "manual"
    })

    return isCodeMessage(response)
}

/**
 * @author: 小佘佘🦀
 * @description: 修改ReportXH
 * @param {ReportType} report
 * */
export const updateReportXH = async (report: ReportType) => {


    const response = await fetch(`/api-backend/api/team/upxh`, {
        method: "POST",
        headers: {
            "content-type": "application/json;charset=utf-8",
        },
        body: JSON.stringify(report),
        redirect: "manual"
    })

    return isCodeMessage(response)
}

/**
 * @author: 小佘佘🦀
 * @description: 修改ReportRID
 * @param {number} rId
 * @param {number} uId
 * */
export const updateReportRID = async (rId: number, uId: number | null) => {

    const params = new URLSearchParams()
    params.append("rId", rId + "");
    params.append("uId", uId + "");

    const response = await fetch(`/api-backend/api/team/uprrid`, {
        method: "POST",
        headers: {
            "content-type": "application/x-www-form-urlencoded",
        },
        body: params.toString(),
        redirect: "manual"
    })

    return isCodeMessage(response)
}

